package com.ljkj.blockpay.network;

import com.ljkj.blockpay.R;
import com.ljkj.blockpay.util.GlobalContext;

import java.io.IOException;
import java.net.InetAddress;
import java.net.URL;


public class HttpUrlHelper {
    public static String getValidUrl(String url) throws IOException {
        try {
            URL netURL = new URL(url);
            InetAddress.getAllByName(netURL.getHost());
        } catch (Exception e) {
            // try to fix bug: GaiException and UnknownHostException
            throw new IOException(GlobalContext.getAppContext().getString(R.string.network_error));
        }
        return url;
    }
}
